package com.jsf.controller;


import com.jsf.entity.Member;
import com.jsf.entity.News;
import com.jsf.service.IMemberService;
import com.jsf.service.INewsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author jsf
 * @since 2022-02-21
 */
@RestController
@RequestMapping("/news")
public class NewsController {
    @Autowired
    private INewsService ns;
    @GetMapping("/selectAll")
    public List<News> selectAll(){
        return ns.list();
    }

    @PostMapping("/add")
    public void add(@RequestBody News news){
        ns.save(news);
    }
    @DeleteMapping("/delete/{id}")
    public void delete(@PathVariable("id") int id){
        ns.removeById(id);
    }
}

